import { Space } from 'antd'
import { memo } from 'react'

interface Props {
  pagination: UsePageProps
  index: number
  record: any
  data: any[]
  moveUp: (record: any) => void
  moveDown: (record: any) => void
}
const MoveSort: React.FC<Props> = (props: Props) => {
  const { pagination, index, record, data, moveUp, moveDown } = props

  return (
    <Space>
      {!(pagination.current === 1 && data.length && record.id === data[0].id) && (
        <div className="cursor-pointer" onClick={() => moveUp(record)}>
          <img className="w-6" src="/static/operationCenter/up.png" alt="" />
        </div>
      )}
      {!((pagination.current - 1) * pagination.pageSize + (index + 1) === pagination.total) && (
        <div className="cursor-pointer" onClick={() => moveDown(record)}>
          <img className="w-6" src="/static/operationCenter/down.png" alt="" />
        </div>
      )}
    </Space>
  )
}

export default memo(MoveSort)
